<style type="text/css">
.device-list li { float:left; width:160px; overflow:hidden; padding:10px; border:1px solid #ddd; margin:6px; background:#fff; cursor:pointer; }
.device-list li b { background:url(/public/images/ui/tree_checkbox_0.gif) left center no-repeat; padding-left:20px; }
.device-list li:hover { border:1px solid #aaa; background:#fff;}
.device-list li.checked { border:2px solid #0099CC; padding:9px; background:#F0F8FD; }
.device-list li.checked b { background:url(/public/images/ui/tree_checkbox_1.gif) left center no-repeat; }
</style>
<script language="javascript">
$(function(){
	$('form').form({ 
		success:function(data){
			var data = runJson(data);
			if(data.status == 0){
				alertText(data.info, 'error');
			}else{
				alertText(data.info, 'success', '{:U('Custom/index')}');
			}
		}   
	}); 
	$('.device-list li').bind('click', function(e){
		var check = $(this).find('input').eq(0).attr('checked');
		if(check){
			$(this).find('input').eq(0).attr('checked', false);
			$(this).removeClass('checked');
		}else{
			$(this).find('input').eq(0).attr('checked', true);
			$(this).addClass('checked');
		}
	});
});
</script>
<div class="wrapper clear">
	<div class="main">
    	<div class="toolbar">
			<a href="{:U('Custom/index')}" class="btn">用户组列表</a>
		</div>
		<div class="search">
            <div class="searchbox">
            	<h3><eq name='ACTION_NAME' value='edit'>编辑用户组<else/>新增用户组</eq></h3>
                <form action="<eq name='ACTION_NAME' value='edit'>{:U('Custom/update')}<else />{:U('Custom/insert')}</eq>&ajax=true" method="post">
                  <table class="tableform" cellpadding="0" cellspacing="0" style="width:900px;">
                    <tr>
                      <th>用户组名称：</th>
                      <td><input type="text" value="{$vo.name}" id="name" name="name" style="width:200px;" class="easyui-validatebox input text" required="true" validType="length[2,20]" /></td>
                    </tr>
                    <tr>
                      <th>排序：</th>
                      <td><input type="text" class="input text" name="sort" id="sort" value="{$vo.sort}" style="width:100px;" /></td>
                    </tr>
                    <tr>
                      <th>备注：</th>
                      <td><textarea class="input textarea" name="remark" id="remark" style="width:300px; height:100px;">{$vo.remark}</textarea><eq name='ACTION_NAME' value='edit'>
                          <input type="hidden" name="custom_id" value="{$vo.custom_id}" />
                        </eq></td>
                    </tr>
                    <tr>
                        <th>终端设备：</th>
                        <td>
                        <ul class="device-list">
                        <?php foreach($device as $dev): ?>
                        <li<?php if(in_array($dev['did'], $device_list)): ?> class="checked"<?php endif;?> title="<?php echo $dev['did'];?>">
                        <label>
                        <input type="checkbox" style="display:none;" value="<?php echo $dev['did'];?>" name="device_list[]"<?php if(in_array($dev['did'], $device_list)): ?> checked<?php endif; ?>/>
                       	<b><?php echo $dev['model']; ?></b>&nbsp;[<?php echo $dev['hwcode'];?>,<?php echo $dev['did'];?>]
                        <br /><span><?php echo $dev['state'].(($dev['state']!=$dev['city']) ? $dev['city'] : ''); ?></span>
                        </label>
                        </li>
                        <?php endforeach; ?>
                        </ul>
                        </td>
                  	</tr>
                    <tr>
                    	<th>&nbsp;</th>
                        <td>
                        <p>注：未选择任何设备表示该用户组成员可使用系统上所有设备。</p>
                        </td>
                    </tr>
                  </table>
                  <!--添加-->
                  <table align="center">
                    <tr>
                      <td align="center"><input class="submit" type="submit" value="保存" id="submits" onclick="return $('form').form('validate')" />
                        <input class="cancel" type="reset" value="取消" /></td>
                    </tr>
                  </table>
                  <!--end添加-->
                </form>
            
            </div>
		</div>
	</div>
</div>		
